using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class pointManager : MonoBehaviour
{
    [SerializeField] private Text pointText;
    private int point;
    public static pointManager instance;

    private void Awake()
    {
        instance = GetComponent<pointManager>();
    }

    public void Start()
    {
        point = 0;
        ShowPoint();
    }
    private void ShowPoint()
    {
        pointText.text = point.ToString();
    }

    public void getPoint(int value)
    {
        point += value;
        ShowPoint();
    }

    public void GameOver()
    {
        if (PlayerPrefs.HasKey("BestPoint"))
        {
            if (PlayerPrefs.GetInt("BestPoint") < point)
            {
                PlayerPrefs.SetInt("BestPoint", point);
            }
        }
        else
        {
            PlayerPrefs.SetInt("BestPoint", point);
        }
    }
}
